package com.example.testanimation.graphics.matrix.image.widget;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.util.AttributeSet;
import android.view.View;
import com.scenic.rd_android.R;

/**
 * Created by scenic on 2015/3/29.
 */
public class MatrixImageView extends View {

    private Bitmap mBitmap;
    private Matrix mMatrix;
    public MatrixImageView(Context context, AttributeSet attrs) {
        super(context, attrs);

        mBitmap = BitmapFactory.
                decodeResource(getResources(),R.mipmap.png_test);

        setImageMatrix(new Matrix());
    }

    public void setImageMatrix(Matrix matrix){
        mMatrix = matrix;
        invalidate();
    }


    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.drawBitmap(mBitmap,0,0,null);
        canvas.drawBitmap(mBitmap, mMatrix,null);
    }
}
